package com.tl.satoken.utils;


import com.tl.satoken.domain.entity.User;
import com.tl.satoken.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class BaseContext {

    private static UserMapper userMapper;

    @Autowired
    public void setUserMapper(UserMapper userMapper) {
        BaseContext.userMapper = userMapper;
    }

    public static ThreadLocal<String> threadLocal = new ThreadLocal<>();

    public static void setCurrentId(String username) {
        threadLocal.set(username);
    }

    public static String getCurrentId() {
        return threadLocal.get();
    }

    public static void removeCurrentId() {
        threadLocal.remove();
    }
}
